package com.autumn.zero.workflow.values;

import javax.validation.constraints.NotNull;

import com.autumn.util.ExceptionUtils;
import com.autumn.zero.workflow.constants.ProcessTaskConstants;

/**
 * 任务完成值
 * 
 * @author 杨昌国 2019-01-28 19:34:52
 */
public class ProcessTaskCompleteValue extends AbstractProcessTaskValue {

	/**
	 * 
	 */
	private static final long serialVersionUID = -1120650546571045891L;

	/**
	 * 任务结果 {@link com.autumn.zero.workflow.constants.ProcessTaskConstants}
	 */
	@NotNull(message = "任务结果不能为空。")
	private Integer taskResult;

	/**
	 * 任务意见
	 */
	private String taskOpinion;

	/**
	 * 
	 * @return {@link com.autumn.zero.workflow.constants.ProcessTaskConstants}
	 */
	public Integer getTaskResult() {
		return taskResult;
	}

	/**
	 * 
	 * @param taskResult
	 *            {@link com.autumn.zero.workflow.constants.ProcessTaskConstants}
	 */
	public void setTaskResult(Integer taskResult) {
		this.taskResult = taskResult;
	}

	public String getTaskOpinion() {
		return taskOpinion;
	}

	public void setTaskOpinion(String taskOpinion) {
		this.taskOpinion = taskOpinion;
	}

	@Override
	public void valid() {
		super.valid();
		if (!(this.getTaskResult().equals(ProcessTaskConstants.AGREE)
				|| this.getTaskResult().equals(ProcessTaskConstants.REFUSE))) {
			ExceptionUtils.throwValidationException("指定的处理结果只能支持同意或拒绝。");
		}
		/*
		 * if (!ProcessTaskConstants.exist(this.getTaskResult()) ||
		 * this.getTaskResult().equals(ProcessTaskConstants.UNKNOWN)) {
		 * ExceptionUtils.throwValidationException("指定的任务结果不支持。"); }
		 */
	}
}
